package com.fanjia.demologin.service.impl;



import com.fanjia.demologin.dao.UserTestDao;
import com.fanjia.demologin.entity.UserTest;
import com.fanjia.demologin.service.UserTestService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户表(UserTest)表服务实现类
 *
 * @author fanjia
 * @since 2021-03-10 15:17:29
 */
@Service("userTestService")
public class UserTestServiceImpl implements UserTestService {
    @Resource
    private UserTestDao userTestDao;



    public  boolean insert(UserTest userTest) {
        boolean insertUser = userTestDao.insert(userTest);

        return insertUser;
    }

    @Override
    public boolean isUserExist(UserTest userTest) {
        //账号是否存在
        boolean isExist = userTestDao.isAccountExist(userTest.getAccount());
        if(isExist){
            //判断密码是否正确
            String password = userTestDao.isPasswordCorrect(userTest.getAccount());
            if(password.equals(userTest.getPassword()) ){
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean phoneIsExist(String phone) {
        boolean phoneWhether =userTestDao.phoneIsExist(phone);
        return phoneWhether;
    }

    @Override
    public boolean checkAccount(UserTest userTest) {
        String account = userTestDao.getAccountbyPhone(userTest.getPhone());

        return account.equals(userTest.getAccount());
    }

    @Override
    public boolean updatePasswordByPhone(UserTest userTest) {
        return userTestDao.updatePasswordByPhone(userTest);
    }


}